[WIP] Use a different port if 3000 is used#100
Conversation
| var execSync = require('child_process').execSync; | ||
| var opn = require('opn'); | ||
| var portfinder = require('portfinder'); | ||
|
|
There was a problem hiding this comment.
I think you can have a var PORT = 3000 here and let the callback of portfinder.getPort re-assign this variable. Then the webpack done callback can just do console.log('The app is running at http://localhost:' + PORT + '/');
|
Updated—now it's working (I think) but UX is still up to debate. I like this way of doing it as the user doesn't have to worry about anything—it'll work and show the available port. |
|
What if you didn't intend to start another secret and just forgot one is already running in a different terminal tab? Ideally we wouldn't want to spend time initializing just to open |
|
Good point. I'm gonna close this in favor of #101, that's looks like a better solution! |
Use ts-jest instead of custom solution for transforming ts files
Work in progress!
Fixes #85.
The idea is to detect if port 3000 is used by something else and if so, use a different port.
portfindertakes in abasePortand returns that if it's available. If not, it'll use the next available port. This was a good solution because we can use 3000 as thebasePort.The problem is that while I can pass the
portto the function that opens the browser, I can't pass it to the function that logsThe app is running at http://localhost:3000/.Assuming this UX is fine (@gaearon wanted a prompt, but I feel like this is less intrusive), how can I let the logging functions know about the new port?
Thanks!